package com.endava.nio_io;

import java.nio.ByteBuffer;

public class Nio_Buffers {
	public static void main(String[] args) {

		ByteBuffer buffer = ByteBuffer.allocate(1024);
		byte[] message = { 'H', 'o', 'w', 'd', 'y' };
		buffer.put(message);
		buffer.put((byte) '!');

		buffer.flip();// new flips over to reading from buffer

		int limit = buffer.limit();// how many chars in buffer
		for (int i = 0; i < limit; i++) {
			System.out.println((char)buffer.get());
		}
	}
}
